<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>行政审批-生产报表页</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
<jsp:include page="/scripts/common/index.html"></jsp:include>
<jsp:include page="/scripts/jquery/index.html"></jsp:include>
<jsp:include page="/scripts/dhtmlx/index.html"></jsp:include>
<jsp:include page="/scripts/bootstrap/index.html"></jsp:include>
<link rel="stylesheet" href="${basePath }style/default.css">
<style>
    h1,h2,h3 {
      text-align: center;
      font-size:18px;
    }
    .table1 {
      width: 100%;
      
      border-radius: 0 0 5px 5px;
      padding-bottom: 50px
    }
    .table1 table tr td, .Table1 table tr th {
      
      height: 26px;
    }
    .table1 table tr th {
       background:#0099cc;
       color:#fff
    }

  *{
		margin: 0;
		padding: 0
	}
		.top,.middle{
			
			float: left;
			height: 50px;
			padding: 5px 10px;
			margin:10px auto 0 auto;		
		}
		.middle {
		width:auto;}
		.top span, .middle{
			font-size: 12px;
		}
		.top input {
			display: inline;
			width:160px;
			background-color:#fff !important;
			cursor: pointer;
		}
		.content{
			width: 490px;
			height: 470px;
			padding: 10px 10px;
			margin:0 auto;
			border: 1px solid #ccc;
			border-top: none;
			border-radius: 0 0 5px 5px;

		}
		button {
			background-color:#0099CC;
			border:none;
			border-radius: 4px;
			width: 60px;
			height: 25px;
			color:#ffffff;
			margin-left:12px;
			font-size: 12px;
			-webkit-transition: all .3s ease-in;
			border:1px solid #fff;
		}
		button:hover {
			border:1px solid #0099CC;
			color: #0099CC;
			background-color: #fff;
		}
		td {
			padding:0 6px
		}
		select {
			height: 28px;
			font-size: 14px;
		}

		br {
			clear: both;
		}
		#header {
			width: 100%;
			border-bottom:1px solid #ccc;
			border-radius: 5px 5px 0 0;
			padding-left:10%
		}
		.td1{
		text-align: left;
		}
		.td2{
		text-align: center;
		}
		.td3{
		text-align: right;
		}
</style>
	<script type="text/javascript">
	var timestart="";
	var timeend="";
	var orglist="";
	//初始化数据
	function init() {
		//请求表格数据
		query();	
		//单位信息
		getorginfo();
		var myCalendar = new dhtmlXCalendarObject({input:"vacationStartDate",button:"calendar_icon"});
		myCalendar.loadUserLanguage("zh");

		myCalendar.setDateFormat("%Y-%m");
		var myCalendar1 = new dhtmlXCalendarObject({input:"vacationStartDate1",button:"calendar_icon"});
		myCalendar1.loadUserLanguage("zh");
		myCalendar1.setDateFormat("%Y-%m");
	}
	//获取单位信息列表
	function getorginfo(){
		$.ajax({
			type : 'POST' ,
			url : 'page/bi/xzsp/getorginfo',
			data : {} ,
			dataType : "json",
			async : true ,
			cache : false ,
			jsonpCallback : "null" ,
			success : function(response, status, statusText) {
				var tablecontent=response.content;
				console.log(tablecontent);
				$("#orglist").append("<option value=''>请选择</option>");
				for(var i=0 ; i<tablecontent.length;i++){
					$("#orglist").append("<option value='"+tablecontent[i].ORG_ID+"'>"+tablecontent[i].NAME+"</option>");
					//console(tablecontent[i].NAME);
				}
			},
			error : function(response, status, statusText) {
			} ,
			complete : function(response, status, statusText) {
			}
		});
	}
	//查询数据
	function select(){
		var timestart=$("#vacationStartDate").val();
		var timeend=$("#vacationStartDate1").val();
		orglist=$("#orglist").find("option:selected").val();
		query();
		//alert(timestart);
		//alert(timeend);
	}
	//清除
	function clear(){
		$("#vacationStartDate").val("");
		$("#vacationStartDate1").val("");
	}
	//查询具体报表数据
	function query() {
		var v =  {};//
		var time= "";
		v["map.StartTime"] = $("#vacationStartDate1").val();//将选择的时间传入后台
		v["map.orglist"] = orglist;//将选择的单位
		
		$('#MyForm').bootstrapValidator('validate');
			$.ajax({
				type : 'POST' ,
				url : 'page/bi/xzsp/getscinfo',
				data : v ,
				dataType : "json",
				async : true ,
				cache : false ,
				jsonpCallback : "null" ,
				success : function(response, status, statusText) {
					
						
						var table="";
						var row="";
						var tablecontent=response.content;
						console.log(tablecontent);
						console.log(tablecontent[1].LEIBIE);
						var ss="<tr>"
					        +"<th  colspan='2' style='text-align:center;width:40%'>指标名称</th>"
					        +"<th style='width: 10%;text-align:center;' >计量单位</th>"
					        +"<th style='width: 25%;text-align:center;'>食品</th>"
					        +"<th style='width: 25%;text-align:center;'>食品添加剂</th>"
					        +"</tr>"
					       //12行
						for(i=0;i<11;i++){
							var sss="<tr>";
							if(tablecontent[0].YX_XKZ==undefined||tablecontent[0].YX_XKZ==""){
								tablecontent[0].YX_XKZ="0";
							}
							if(tablecontent[0].SY_HZQYS==undefined||tablecontent[0].SY_HZQYS==""){
								tablecontent[0].SY_HZQYS="0";
							}
							if(tablecontent[0].SLXKSQS==undefined||tablecontent[0].SLXKSQS==""){
								tablecontent[0].SLXKSQS="0";
							}
							if(tablecontent[0].ZX_XKZ==undefined||tablecontent[0].ZX_XKZ==""){
								tablecontent[0].ZX_XKZ="0";
							}
							if(tablecontent[0].GQXKZS==undefined||tablecontent[0].GQXKZS==""){
								tablecontent[0].GQXKZS="0";
							}
							if(tablecontent[0].BQHZZSS==undefined||tablecontent[0].BQHZZSS==""){
								tablecontent[0].BQHZZSS="0";
							}
							if(tablecontent[0].BQHZQYS==undefined||tablecontent[0].BQHZQYS==""){
								tablecontent[0].BQHZQYS="0";
							}
							if(tablecontent[0].SQZXXKZS==undefined||tablecontent[0].SQZXXKZS==""){
								tablecontent[0].SQZXXKZS="0";
							}
							if(tablecontent[0].BGXKZS==undefined||tablecontent[0].BGXKZS==""){
								tablecontent[0].BGXKZS="0";
							}
							if(tablecontent[0].BGXKQYS==undefined||tablecontent[0].BGXKQYS==""){
								tablecontent[0].BGXKQYS="0";
							}
							if(tablecontent[1].YX_XKZ==undefined||tablecontent[1].YX_XKZ==""){
								tablecontent[1].YX_XKZ="0";	
							}
							if(tablecontent[1].SY_HZQYS==undefined||tablecontent[1].SY_HZQYS==""){
								tablecontent[1].SY_HZQYS="0";
							}
							if(tablecontent[1].SLXKSQS==undefined||tablecontent[1].SLXKSQS==""){
								tablecontent[1].SLXKSQS="0";
							}
							if(tablecontent[1].ZX_XKZ==undefined||tablecontent[1].ZX_XKZ==""){
								tablecontent[1].ZX_XKZ="0";
							}
							if(tablecontent[1].GQXKZS==undefined||tablecontent[1].GQXKZS==""){
								tablecontent[1].GQXKZS="0";
							}
							if(tablecontent[1].BQHZZSS==undefined||tablecontent[1].BQHZZSS==""){
								tablecontent[1].BQHZZSS="0";	
							}
							if(tablecontent[1].SQZXXKZS==undefined||tablecontent[1].SQZXXKZS==""){
								tablecontent[1].SQZXXKZS="0";
							}
							if(tablecontent[1].BQHZQYS==undefined||tablecontent[1].BQHZQYS==""){
								tablecontent[1].BQHZQYS="0";
							}
							if(tablecontent[1].BGXKZS==undefined||tablecontent[1].BGXKZS==""){
								tablecontent[1].BGXKZS="0";
							}
							if(tablecontent[1].BGXKQYS==undefined||tablecontent[1].BGXKQYS==""){
								tablecontent[1].BGXKQYS="0";
							}
							if(i==0){
							sss+="<td colspan='2' class='td1'>截至本期末有效许可证书数</td>";
							sss+="<td class='td2'>张</td>";
							sss+="<td class='td3'>"+tablecontent[0].YX_XKZ+"</td>";
							sss+="<td class='td3'>"+tablecontent[1].YX_XKZ+"</td>";
							}
							if(i==1){
								sss+="<td colspan='2' class='td1'>截至本期末实有获证企业数</td>";
								sss+="<td class='td2'>家</td>";
								sss+="<td class='td3'>"+tablecontent[0].SY_HZQYS+"</td>";
								sss+="<td class='td3'>"+tablecontent[1].SY_HZQYS+"</td>";
							}
							//if(i==2){
							//	sss+="<td colspan='2' class='td1'>本期受理许可申请数</td>";
							//	sss+="<td class='td2'>件</td>";
							//	sss+="<td class='td3'>"+tablecontent[0].SLXKSQS+"</td>";
							//	sss+="<td class='td3'>"+tablecontent[1].SLXKSQS+"</td>";
							//}
							if(i==4){
								sss+="<td colspan='2' class='td1'>本期注销许可证数</td>";
								sss+="<td class='td2'>张</td>";
								sss+="<td class='td3'>"+tablecontent[0].ZX_XKZ+"</td>";
								sss+="<td class='td3'>"+tablecontent[1].ZX_XKZ+"</td>";
								}
							if(i==5){
								sss+="<td rowspan='2' width='80px' class='td2'>其中</td>";
								sss+="<td >本期申请注销许可证数</td>";
								sss+="<td class='td2'>张</td>";
								sss+="<td class='td3'>"+(tablecontent[0].SQZXXKZS)+"</td>";
								sss+="<td class='td3'>"+(tablecontent[1].SQZXXKZS)+"</td>";
								}
								if(i==6){
									sss+="<td class='td1'>本期过期许可证数</td>";
									sss+="<td class='td2'>张</td>";
									sss+="<td class='td3'>"+tablecontent[0].GQXKZS+"</td>";
									sss+="<td class='td3'>"+tablecontent[1].GQXKZS+"</td>";
								}
								if(i==7){
									sss+="<td colspan='2' class='td1'>本期换证证书数</td>";
									sss+="<td class='td2'>张</td>";
									sss+="<td class='td3'>"+tablecontent[0].BQHZZSS+"</td>";
									sss+="<td class='td3'>"+tablecontent[1].BQHZZSS+"</td>";
								}
								if(i==8){
									sss+="<td colspan='2' class='td1'>本期换证企业数</td>";
									sss+="<td class='td2'>家</td>";
									sss+="<td class='td3'>"+tablecontent[0].BQHZQYS+"</td>";
									sss+="<td class='td3'>"+tablecontent[1].BQHZQYS+"</td>";
								}
								if(i==9){
									sss+="<td colspan='2' class='td1'>本期变更许可证书数</td>";
									sss+="<td class='td2'>张</td>";
									sss+="<td class='td3'>"+tablecontent[0].BGXKZS+"</td>";
									sss+="<td class='td3'>"+tablecontent[1].BGXKZS+"</td>";
								}
								if(i==10){
									sss+="<td colspan='2' class='td1'>本期变更许可企业数</td>";
									sss+="<td class='td2'>家</td>";
									sss+="<td class='td3'>"+tablecontent[0].BGXKQYS+"</td>";
									sss+="<td class='td3'>"+tablecontent[1].BGXKQYS+"</td>";
								}
							sss+="</tr>";
							ss=ss+sss;
						}	
						$("#tables3").html(ss);
						//$("#tables3").find("td").css("text-align","center")
						
				} ,
				error : function(response, status, statusText) {
				} ,
				complete : function(response, status, statusText) {
				}
			});
		
	}
	//清除数据
	function clearData(){
		
		var arr = ["vacationStartDate","vacationStartDate1"];
		for(key in arr){
			$("#"+arr[key]+"").val("")
		}
		$("#orglist option:first").prop("selected", 'selected');
		orglist="";
		query();
	}
	</script>
<style type="text/css">
  br {
    clear: both;
  }
</style>
  </head>
  
  <body onload="init()" style="margin: 0;" margin-top="0">
    <div style="display: flex">
    <!-- 右边的div -->
    <div id="tables" style="overflow:auto;width:auto;flex: 1;">
    <div id="header">
	<div class="top">
		<!--  <span>统计时间:&nbsp;&nbsp;从</span>
		<input type="text" id="vacationStartDate" class="form-control" readonly="true" /> -->
		<span>&nbsp;&nbsp;时间范围：&nbsp;&nbsp;</span>
		<input type="text" id="vacationStartDate1" class="form-control" readonly="true" />
	</div>
	<div class="middle">
		<label style="font-weight: normal">单位:</label>
		<select style="width:210px;border-radius: 5px;padding: 0 10px;font-size:12px" id="orglist"></select>
		<button onclick="select()">查询</button>
		<button onclick="clearData()">清空</button>
		<!-- 
		<button>清空</button>
		 -->
	</div>
	<br>
	</div>
     <div id="Table2" class="table1">
      <h1 style="margin:24px 0">食品生产许可情况</h1>
    	<table border="1" id="tables3"  bordercolor="#ccc" width="80%" border-collapse="cellspacing" cellspacing="0" align='center' style="margin:0 auto">
          
    </table>
    </div>
          <br/><br/><br/>
    </div>
    </div>
  </body>
</html>
